#include <stdio.h>

#define N 100011

int prime[N] = {0};
int NextPrime(int x)
{
    int p = 2, q = 2;
    while (p < N && (p < x || prime[p]))
    {
        do
        {
            long long t = (long long)p * q;
            if (t < N)
                prime[p * q] = 1;
        } while (p % q++ != 0);
        q = 2;
        p++;
    } // 3 * 3 = 9(筛), 3 % 3 == 0 退出
    return p;
}